﻿@model INSE6260.OnlineBanking.Model.Payee.Payee

@{
    ViewBag.Title = "Create New Payee";
}
<h2>Create New Payee</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    function OnChange() {
        $.ajax({
            type: "GET",
            url: "/PayeeInfo/GetInstruction?" + "payeenameId=" + $("#PNameId").val(),
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            cashe: false,
            success: function (res) {
                $("#Instruction").html("Account No(" + res+")");
            }
        });
    }
    
</script>
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Payee</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.PayeeNameId, "PayeeName")
        </div>
        <div class="editor-field">
            @Html.ListBoxFor(model => model.PayeeNameId, new SelectList(ViewBag.PayeeNameList, "Id", "Name"), new {id="PNameId",@class="List", onchange = "OnChange()" })
            
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NickName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.NickName)
            @Html.ValidationMessageFor(model => model.NickName)
        </div>

        <div class="editor-label" id="Instruction">
            Account No
        </div>
        <div class="editor-field">
            
                    @Html.EditorFor(model => model.AccountNo)
                    @Html.ValidationMessageFor(model => model.AccountNo)
                
            
        </div>
        <p>
            <input type="submit" value="Create" />
            @Html.ActionLink("Cancel", "Index", "PayeeInfo", null, new { @class = "khbtn" })
        </p>
    </fieldset>
}

